<?php
include('includes/functions.php');
if ($_POST) {
	if (login($_POST['username'], $_POST['password'])) {
		if ($_GET['redirect_to']) header("Location: ". $_GET['redirect_to']);
		else header("Location: /calendar/main.php");
	} else {
		$error = "Incorrect Login";
	}
}
$title = "Login";
include('includes/header.php');
?>
<p class='welcome-head'>Please login with a valid @gwmail.gwu.edu address to continue.</p>

<?php if (sizeof($error)>0) { ?>
<div class='bad-news'><?php echo $error; ?></div>
<?php } ?>
<?php if ($_GET['action']=="logout") { ?>
<div class='good-news'>You have logged out sucesfully</div>
<?php } ?>
<?php if ($_GET['redirect_to']) { ?>
<div class='bad-news'>You must be logged in to view that page.</div>
<?php } ?>
	<form method='post'>
		<div class='form-row'>
			<div class='form-label'><label for='username'>E-mail:</label></div>
			<div class='form-field'><input type='text' name='username' id='username' size='15' />@gwmail.gwu.edu</div>
		</div>
		<div class='form-row'>
			<div class='form-label'><label for='password'>Password:</label></div>
			<div class='form-field'><input type='password' name='password' id='password' size='30' /></div>
		</div>
		<div class='form-row'>
			<div class='form-label'> &nbsp </div>
			<div class='form-field'><input type='submit' value='Login' /> [ <a href="isthissafe.html?keepThis=true&TB_iframe=true&height=250&width=400" title="" class="thickbox">is this safe?</a> ] </div>
			
		</div>
	</form>
	<div class='clear'> &nbsp </div>


<?php include('includes/footer.php'); ?>